package util;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;



import com.jcraft.jsch.JSchException;


public class QADTimer {
	public void everyDayat0730(){
		Calendar calendar = Calendar.getInstance();
	    calendar.set(Calendar.HOUR_OF_DAY, 07); // 控制�?
	    calendar.set(Calendar.MINUTE, 30);    // 控制�?
	    calendar.set(Calendar.SECOND, 0);    // 控制�?
	    Date time = calendar.getTime();     // 得出执行任务的时�?,此处为今天的12�?00�?00
	    QADTimer taskScheduler=new QADTimer();
		Timer timer=new Timer();
	    timer.scheduleAtFixedRate(new TimerTask() {
	      public void run() {
	    	  String ftpPath = Constant.FPTPATH;
//	    	  String fileNamePs = "sfc_171007-171013.csv";
	  		SFtpUtil sFtpUtil = new SFtpUtil();
	  		try {
				sFtpUtil.downloadSftpFile(ftpPath,Constant.OAPCDATE);
				System.out.println("定时获取"+Constant.OAPCDATE+"文件计划启动成功");
				sFtpUtil.downloadSftpFile(ftpPath,Constant.OAPTDATE);
				System.out.println("定时获取"+Constant.OAPTDATE+"文件计划启动成功");
				sFtpUtil.downloadSftpFile(ftpPath,Constant.OAVDDATE);
				System.out.println("定时获取"+Constant.OAVDDATE+"文件计划启动成功");
			} catch (JSchException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	      }
//	    }, time, 1000 * 60 * 60 * 24);// 这里设定将延时每天固定执�?
	    }, time, 86400000);// 这里设定将延时每天固定执�?
	}
	
	public void everyDayat1230(){
		Calendar calendar = Calendar.getInstance();
	    calendar.set(Calendar.HOUR_OF_DAY, 12); // 控制�?
	    calendar.set(Calendar.MINUTE, 30);    // 控制�?
	    calendar.set(Calendar.SECOND, 0);    // 控制�?
	    Date time = calendar.getTime();     // 得出执行任务的时�?,此处为今天的12�?00�?00
	    QADTimer taskScheduler=new QADTimer();
		Timer timer=new Timer();
	    timer.scheduleAtFixedRate(new TimerTask() {
	      public void run() {
	    	  String ftpPath = Constant.FPTPATH;
//	    	  String fileNamePs = "sfc_171007-171013.csv";
	  		SFtpUtil sFtpUtil = new SFtpUtil();
	  		try {
	  			sFtpUtil.downloadSftpFile(ftpPath,Constant.OAPCDATE);
				System.out.println("定时获取"+Constant.OAPCDATE+"文件计划启动成功");
				sFtpUtil.downloadSftpFile(ftpPath,Constant.OAPTDATE);
				System.out.println("定时获取"+Constant.OAPTDATE+"文件计划启动成功");
				sFtpUtil.downloadSftpFile(ftpPath,Constant.OAVDDATE);
				System.out.println("定时获取"+Constant.OAVDDATE+"文件计划启动成功");
			} catch (JSchException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	      }
//	    }, time, 1000 * 60 * 60 * 24);// 这里设定将延时每天固定执�?
	    }, time, 86400000);// 这里设定将延时每天固定执�?
	}
}
